package com.flycent.hqhs.ui;

import net.tsz.afinal.FinalActivity;
import net.tsz.afinal.annotation.view.ViewInject;

import com.flycent.hqhs.App;
import com.flycent.hqhs.R;
import com.flycent.hqhs.http.WebClient;
import com.flycent.hqhs.http.WebException;
import com.flycent.hqhs.util.ContextUtil;

import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;

/** 账户管理 */
public class AccountManagementActivity extends BackableTitleBarActivity{
	@ViewInject(id = R.id.account_address_manager_relat , click = "butClick") RelativeLayout mAddressRelat;
	@ViewInject(id = R.id.account_password_manager_relat , click = "butClick") RelativeLayout mPassWordRelat;
	@Override
	protected void onCreate(Bundle savedInstance) {
		super.onCreate(savedInstance);
		setContentView(R.layout.activity_account_management);
		FinalActivity.initInjectedView(this);
		getTitleBar().setTitle(R.string.mine_account_manage);

		doJudgeLogin();
	}

	private void doJudgeLogin() {
		new Thread(){
			public void run() {
				try {
					WebClient.getInstance(AccountManagementActivity.this).checkLogin();

				} catch (WebException e) {
					if( "shop.common.unauthorized".equals(e.getStatusCode()) ){
						App.showShortToast("登录过期,请重新登录!");
						AccountManagementActivity.this.finish();
					}
				}
			};
		}.start();

	}

	public void butClick(View v){
		//地址管理
		if( v == mAddressRelat ){
			ContextUtil.startActivity(this, AddressManagerActivity.class);			

		}
		//密码修改
		if( v == mPassWordRelat ){
			ContextUtil.startActivity(this, ModifyPwdActivity.class);
		}

	}

}
